﻿using System;
using System.Net;
using System.IO;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Interactivity;
using Microsoft.Xna.Framework.Media;
using System.Windows.Media.Imaging;

namespace euphoriaBehaviorsLibrary
{
    public class SaveScreenShotAction : TargetedTriggerAction<DependencyObject>
    {
        protected override void Invoke(object parameter)
        {
            WriteableBitmap bitmap = new WriteableBitmap((UIElement)base.Target, null);
            MemoryStream stream = new MemoryStream();
            bitmap.SaveJpeg(stream, bitmap.PixelWidth, bitmap.PixelHeight, 0, 100);
            using (MediaLibrary medialib = new MediaLibrary())
                medialib.SavePicture(DateTime.Now.ToString("yyMMddHHmmss"), stream.ToArray());
            MessageBox.Show("Saved");
        }
    }
}

